using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using IReaper.FileData;

namespace IReaper.Statues
{
    public partial class ImportFileWork : AsyncWork
    {
        string path;
        bool overwrite;
        public ImportFileWork(string Path, bool overwrite)
            : this()
        {
            this.path = Path;
            this.overwrite = overwrite;
        }

        public ImportFileWork()
        {
            InitializeComponent();
        }

        public ImportFileWork(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }

        protected override void OnDoWork(DoWorkEventArgs e)
        {
            base.OnDoWork(e);
            ProgressChangedEventHandler OnProgress = OnProgressChanged;
            FileUtils.FileTransferManager.ImportCourseFileDataFromExportedFolder(this.path, this.overwrite, OnProgressChanged);
        }

        private void OnProgressChanged(object sender,ProgressChangedEventArgs e)
        {
            base.OnProgressChanged(e);
            this.Status.Percentage = e.ProgressPercentage;
            CourseFileData cFile = e.UserState as CourseFileData;
            if (cFile == null)
                return;
            this.Status.TaskMessage = Properties.Resources.ImportFileNotificationMessage + cFile.Owner.Headline;
        }
    }
}
